package gameEngine.agents.choosingStrategy;

import java.util.ArrayList;

import org.apache.log4j.Logger;

import gameEngine.agents.teamMateModel.TeamMateModel;
import gameEngine.experiments.ExperimentImpl;

public abstract class AdaptiveStrategy implements ChoosingStrategy {

	public ArrayList<ChoosingStrategy> strategies=new ArrayList<ChoosingStrategy>();
	public ArrayList<Integer> strategiesTurn=new ArrayList<Integer>();
	int currentStrategy;
	int turn=0;
	Logger log = Logger.getLogger(AdaptiveStrategy.class);
	
	public AdaptiveStrategy(){
		super();
	}
	
	public void addStrategy(ChoosingStrategy strategy,int turnNumber){
		strategies.add(strategy);
		strategiesTurn.add(turn+turnNumber);
		log.debug("Strategy "+strategy.toString()+" add and will end at turn "+(turn+turnNumber));
		turn=turn+turnNumber;
	}
	
	
	public abstract int chooseNextPlayer(TeamMateModel teamMateModel);

	
	public void setStrategies(ArrayList<ChoosingStrategy> strategies) {
		this.strategies = strategies;
	}
	
	public ArrayList<ChoosingStrategy> getStrategies(){
		return strategies;
	}

	public void setStrategiesTurn(ArrayList<Integer> strategiesTurn) {
		this.strategiesTurn = strategiesTurn;
	}
	
	public ArrayList<Integer> getStrategiesTurn(){
		return strategiesTurn;
	}
	
	public abstract void updateTurn();
	
	//a copy constractur
	public AdaptiveStrategy(ArrayList<ChoosingStrategy> strats,ArrayList<Integer> turns){
		
 		for(int i=0;i<strats.size();i++){
 			addStrategy(strats.get(i).clone(), turns.get(i));
 		}
	}
	
	public AdaptiveStrategy clone(){
		if(this instanceof ManuallAdaptiveStrategy){
			return new ManuallAdaptiveStrategy(getStrategies(),getStrategiesTurn());
		}else{
			return null;
		}
	}
	
}
